﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:skin="clr-namespace:UBCon.Ribbon.SkinManagers"
                    xmlns:ubcr="clr-namespace:UBCon.Ribbon"
                    xmlns:effect="clr-namespace:UBCon.Resources.Effects;assembly=UBCon.Resources">


    <SolidColorBrush Color="#FFE7F1FC" x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBackgroundBrush}" />

    <SolidColorBrush Color="#FF527DE0" x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBorderBrush}" />

    <SolidColorBrush Color="#FF93C6FF" x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=PressedBackgroundBrush}" />

    <ControlTemplate TargetType="{x:Type Button}"
                     x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=AppMenuButtonTemplate}">
        <Grid>
            <Border x:Name="OuterBorder" 
                    CornerRadius="3,3,0,0"
                    BorderThickness="1" 
                    BorderBrush="#FF1F48A1" 
                    Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MSWord2010AppMenuBackgroundBrush}}">
                <Border CornerRadius="3,3,0,0" 
                        BorderThickness="1,1,1,0" 
                        BorderBrush="#FF3374C7" 
                        x:Name="InnerBorder" />
            </Border>
            <TextBlock Padding="{Binding Path=Padding, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}" 
                       Text="{Binding Path=Content, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                       Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" 
                       VerticalAlignment="Center" 
                       TextAlignment="Center" 
                       HorizontalAlignment="Stretch" />
        </Grid>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background" TargetName="OuterBorder">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FF215AAE" Offset="0.431"/>
                                <GradientStop Color="#FF215AB0" Offset="0.216"/>
                                <GradientStop Color="#FF6495E9" Offset="0.845"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FF4383D4" TargetName="InnerBorder"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" TargetName="OuterBorder">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="#FF215AAE" Offset="0.431"/>
                            <GradientStop Color="#FF215AB0" Offset="0.216"/>
                            <GradientStop Color="#FF6495E9" Offset="0.845"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="BorderThickness" Value="1,1,1,0" TargetName="OuterBorder"/>
                <Setter Property="BorderBrush" Value="#FF3670D4" TargetName="InnerBorder"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <BooleanToVisibilityConverter x:Key="converter" />
    
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=NoneSelectableApplicationMenuItemTemplate}"
                     TargetType="{x:Type ubcr:ApplicationMenuItem}">
        <ubcr:RibbonChrome BorderThickness="1" 
                              InnerBorderThickness="1" 
                              Height="24" 
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                              MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBorderBrush}}" 
                              MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBackgroundBrush}}" 
                              CornerRadius="3"
                              InnerBorderCornerRadius="3" 
                              RenderMouseOver="{TemplateBinding IsMouseOver}"
                              PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=PressedBackgroundBrush}}" 
                              InnerBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBackgroundBrush}}" 
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"
                              RenderPressed="{TemplateBinding IsPressed}" 
                              PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBorderBrush}}" 
                              Padding="2, 0, 2, 0">
            <Grid MinWidth="{TemplateBinding MinWidth}" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Image Source="{TemplateBinding Image}" 
                           Width="16" 
                           Height="16" 
                           HorizontalAlignment="Center" 
                           VerticalAlignment="Center" 
                           RenderOptions.BitmapScalingMode="HighQuality" 
                           Stretch="Fill" 
                           Margin="15, 0, 0, 0"/>
                <TextBlock Margin="5, 0, 0, 0" 
                           Grid.Column="1" 
                           Text="{TemplateBinding TitleContent}" 
                           TextAlignment="Left" 
                           VerticalAlignment="Center" />
            </Grid>
        </ubcr:RibbonChrome>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=SelectableApplicationMenuItemTemplate}"
                     TargetType="{x:Type ubcr:ApplicationMenuItem}">
        <ubcr:RibbonChrome x:Name="chrome" 
                          Margin="0, 2, 0, 0"
                          BorderThickness="0,1,0,1" 
                          InnerBorderThickness="0"
                          Height="40" 
                          BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                          MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBorderBrush}}" 
                          MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBackgroundBrush}}" 
                          CornerRadius="0"
                          InnerBorderCornerRadius="0" 
                          PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=PressedBackgroundBrush}}" 
                          InnerBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                          PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=MouseOverBorderBrush}}" 
                          Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                          >
            <Grid MinWidth="{TemplateBinding MinWidth}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" x:Name="imageColumn" />
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="text" 
                           Text="{TemplateBinding TitleContent}" 
                           Margin="25, 0, 0, 0" 
                           TextAlignment="Left"  
                           HorizontalAlignment="Stretch" 
                           VerticalAlignment="Center" 
                          FontSize="12" />
                <Image Grid.Column="1"
                       Height="16" 
                       Width="16" 
                       HorizontalAlignment="Right"
                       Visibility="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource ResourceKey=converter}}">
                    <Image.Source>
                        <DrawingImage RenderOptions.BitmapScalingMode="HighQuality">
                            <DrawingImage.Drawing>
                                <DrawingGroup>
                                    <GeometryDrawing Geometry="M 4 0 L 0 3.5 L 4 7 Z"
                                                     Brush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}">
                                        <GeometryDrawing.Pen>
                                            <Pen Brush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                                                Thickness="1" />
                                        </GeometryDrawing.Pen>
                                    </GeometryDrawing>
                                </DrawingGroup>
                            </DrawingImage.Drawing>
                        </DrawingImage>
                    </Image.Source>
                </Image>
            </Grid>
        </ubcr:RibbonChrome>
        
        <ControlTemplate.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" TargetName="chrome">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="#FF215AAE" Offset="0.431"/>
                            <GradientStop Color="#FF215AB0" Offset="0.216"/>
                            <GradientStop Color="#FF6495E9" Offset="0.845"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="MouseOverBackgroundBrush" 
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                        TargetName="chrome"/>
                <Setter Property="BorderThickness" 
                        Value="0" 
                        TargetName="chrome"/>
                <Setter Property="InnerBorderThickness" 
                        Value="0" 
                        TargetName="chrome"/>
                <Setter Property="Foreground" 
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" 
                        TargetName="text"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="False" />
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="RenderMouseOver" Value="True" TargetName="chrome"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    <Style TargetType="{x:Type ubcr:ApplicationMenuItem}">
        <Setter Property="MinWidth" Value="150" />
        <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}"/>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect DesaturationFactor="0.0" />
                    </Setter.Value>
                </Setter>

            </Trigger>
            <Trigger Property="IsSelectable" Value="False">
                <Setter Property="Margin" Value="6, 0"/>
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=NoneSelectableApplicationMenuItemTemplate}}"/>
            </Trigger>
            <Trigger Property="IsSelectable" Value="True">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=SelectableApplicationMenuItemTemplate}}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    <DrawingImage x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LeftArrowImage_DefaultState}"
                  RenderOptions.BitmapScalingMode="HighQuality">
        <DrawingImage.Drawing>
            <GeometryDrawing Geometry="M15,4 L3,4 L7,0 L5,0 L0,5 L5,10 L7,10 L3,6 L15,6z" 
                             Brush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBackgroundBrush}}">
                <GeometryDrawing.Pen>
                    <Pen Brush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBackgroundBrush}}" 
                         Thickness="0.6" />
                </GeometryDrawing.Pen>
            </GeometryDrawing>
        </DrawingImage.Drawing>
    </DrawingImage>

</ResourceDictionary>